//
//  YWBuildingAndLocationCell.m
//  maintain
//
//  Created by 郑想 on 16/7/28.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWBuildingAndLocationCell.h"
#import "UIColor+CustomColors.h"
#import "Masonry.h"

@implementation YWBuildingAndLocationCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    YWBuildingAndLocationCell *cell = [tableView dequeueReusableCellWithIdentifier:YWBuildingAndLocationCellIdentifier];
    if (cell == nil) {
        cell = [[YWBuildingAndLocationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:YWBuildingAndLocationCellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView *superview = self.contentView;
        superview.backgroundColor = [UIColor customBlueColor];
        
        _bulidingNameLabel = [UILabel new];
        _bulidingNameLabel.textColor = [UIColor whiteColor];
        _bulidingNameLabel.font = [UIFont systemFontOfSize:17];
        [superview addSubview:_bulidingNameLabel];
        
        _bulidingLocationLabel = [UILabel new];
        _bulidingLocationLabel.textColor = [UIColor whiteColor];
        _bulidingLocationLabel.font = [UIFont systemFontOfSize:17];
        [superview addSubview:_bulidingLocationLabel];
    }
    return self;
}

// tell UIKit that you are using AutoLayout
+ (BOOL)requiresConstraintBasedLayout {
    return YES;
}

// this is Apple's recommended place for adding/updating constrains
- (void) updateConstraints {
    //adding/updating constrains
    UIView *superview = self.contentView;
    [_bulidingNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(superview).offset(8);
    }];
    [_bulidingLocationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_bulidingNameLabel.mas_bottom).offset(6);
        make.left.mas_equalTo(_bulidingNameLabel);
    }];
    //according to apple super should be called at end of method
    [super updateConstraints];
}



@end
